﻿@{
    var _forums = ViewBag.ForumList as List<Forum>;
    var _url = ViewBag.ActiveUrl as ForumUrl;
}
@model Forum
<div class="site-block">
    <div class="header">
        @ViewBag.ActiveUrl.Title
    </div>
    @using (Html.Kaio().BeginForm(new jQueryAjaxOptions { Loading = true,Type = AjaxRequestDataType.Script}, new { @id = "_f" }))
    {

        @Html.HiddenFor(x => Model.ForumId)
        @Html.Hidden("returnUrl", _url.Url)
        <div class="site-block-content">
            <table>
                <tr>
                    <td class="w25">
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "FORUM_NAME")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.ForumName, new { @class = "input {validate:{required:1}}" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "ICON")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.Icon, new { @class = "input" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "PARENT")
                    </td>
                    <td>
                        @Html.DropDownList("ParentId", (List<SelectListItem>)ViewBag.ParentList, new { @class = "select" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "KEYWORDS")
                    </td>
                    <td>
                        @Html.TextAreaFor(x => Model.Keywords, new { @class = "input" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "DESCRIPTION")
                    </td>
                    <td>
                        @* @Html.TextAreaFor(x => Model.Description, new { @class = "input" })*@
                        @Html.Kaio().EditorFor(x => x.Description, new EditorOptions() { ToolbarMode = EditorToolbarMode.Small })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "SORT_ORDER")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.SortOrder, new { @class = "input {validate:{required:true,digits:true}}" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "REMOTE_URL")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.RemoteUrl, new { @class = "input {validate:{url:1}}" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "ALLOW_ROLE")
                    </td>
                    <td>
                        @Html.CheckBoxGroup("AllowRoles", (List<SelectItem>)ViewBag.AllowRoles, Model != null ? Model.Roles : null, new { @class = "checkbox-group" })
                        @* @Html.ListBox("AllowRoles", new MultiSelectList(ViewBag.AllowRoles, "RoleId", "RoleName",_select), new { @class = "select", @style = "height:100px;width:90%" })*@
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "MODERATE_TYPE")
                    </td>
                    <td>
                        @*@Html.DropDownList("ModerateType", new SelectList(ViewBag.ModerateType,"Value","Text",1), new { @class = "select" })*@
                        @Html.DropDownList("ModerateType", (List<SelectItem>)ViewBag.ModerateTypes, new { @class = "select" })
                    </td>
                </tr>
                <tr>
                    <td class="caption" colspan="2">
                        @ForumContext.GetText(LanguageSection.FORUM_MANAGER, "OPTIONS")
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "SORT_ORDER_BY")
                    </td>
                    <td>
                        @Html.DropDownList("OrderBy", (List<SelectItem>)ViewBag.SortOrderBy, new { @class = "select" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "SORT_DIRECTION")
                    </td>
                    <td>
                        @Html.DropDownList("SortDirection", (List<SelectListItem>)ViewBag.SortDir, new { @class = "select" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "TOPICS_PER_PAGE")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.TopicsPerPage, new { @class = "input {validate:{required:true,digits:true}}", style = "width:150px" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "POSTS_PER_PAGE")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.PostsPerPage, new { @class = "input {validate:{required:true,digits:true}}", style = "width:150px" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "IsLocked")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("IsLocked", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.IsLocked, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "ALLOW_POST_WITH_IN")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("AllowPostWithIn", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.AllowPostWithIn, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "VISIBLE_AT_HOME_PAGE")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("VisibleAtHomePage", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.VisibleAtHomePage, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.FORUM_MANAGER, "INCREASE_MEMBER_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("IncreaseMemberPosts", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.IncreaseMemberPosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        @Html.Link("javascript://", (string)ViewBag.ButtonText, new { @class = "ui-button", onclick = "$('#_f').submit()" })
                        @Html.Link(_url.Url, ForumContext.GetText(LanguageSection.GLOBAL, "Cancel"), new { @class = "ui-button" })
                    </td>
                </tr>
            </table>
        </div>
    }
</div>
@if (_forums != null && _forums.Count > 0)
{
    
    <form action="@_url.Url" id="_fl">
    @Html.Hidden("act", "del")
    @Html.Hidden("ReturnUrl", _url.Url)
    <div class="gridview white-t">
        <div class="head">
            @ForumContext.GetText(LanguageSection.FORUM_MANAGER, "FORUM_LIST")
        </div>
        <table class="datatable">
            <tr>
                <th class="header w5" scope="col">
                    <input type='checkbox' onclick='$.MvcForum.toggleCheckbox(this.checked)' />
                </th>
                <th class="header" scope="col">
                    Forum Name
                </th>
                <th class="header" scope="col">
                    Topics
                </th>
                <th class="header" scope="col">
                    SortOrder
                </th>
                <th class="header" scope="col">
                    Option
                </th>
            </tr>
            @foreach (var f in _forums)
            {
                <tr class="row" id="@string.Format("row_{0}", f.ForumId)">
                    <td class="center">
                        <input type="checkbox" name="Ids" value="@f.ForumId" class="selected" />
                    </td>
                    <td class="@string.Format("{0}", f.ParentId == 0 ? "bold" : string.Empty)">
                        @string.Format("{0}{1}", ForumContext.Padding(f.Level), f.ForumName)
                    </td>
                    <td class="center width10">
                        @f.TotalTopics
                    </td>
                    <td class="center width10">
                        @f.SortOrder
                    </td>
                    <td class="center width10">
                        @Html.Link(string.Format("{0}?Id={1}", (string)ViewBag.Url, f.ForumId), "", new { @class = "ui-button icon-16 edit" })
                    </td>
                </tr>
                
                
            }
        </table>
    </div>
    <div class="white-t">
        @Html.Link("javascript:void(0)", "", new { @onclick = "$.KoolBox.confirm('" + ForumContext.GetText(LanguageSection.MESSAGES, "DELETE_CONFIRM") + "',{title:'Confirm'},function(r){if(r){$.MvcForum.ajaxSubmit('_fl')}})", @class = "ui-button icon-16 del" })
    </div>
    </form>
    
}